package jee.boot.module.iexp.excel.excel;

import jee.boot.common.utils.DateUtils;
import jee.boot.common.utils.Reflections;
import jee.boot.common.utils.StringUtils;
import jee.boot.common.utils.excel.annotation.ExcelField;
import jee.boot.common.utils.excel.annotation.ExcelField.Type;
import jee.boot.common.utils.excel.excel.ErrorMessage;
import jee.boot.common.utils.excel.excel.ExcelException;
import jee.boot.common.utils.excel.service.DictionaryTranslateHelper;
import jee.boot.common.utils.excel.service.EntityTranslateHelper;
import jee.boot.common.utils.excel.service.MethodCall;
import jee.boot.entity.task.ExcelUtils;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;


/**
 * 导入Excel文件（支持“XLS”和“XLSX”格式）
 *
 * @version 2018-08-11
 */
public class ExcelImport implements Closeable {

    private static Logger log = LoggerFactory.getLogger(ExcelImport.class);

    /**
     * 工作薄对象
     */
    private Workbook wb;

    /**
     * 工作表对象
     */
    private Sheet sheet;

    /**
     * 标题行数
     */
    private int headerNum;

    // 针对导入到数据到map的时候使用
    private String startColumn = "A";//开始列 默认从第一列开始
    private String endColumn = "Z";//结束列 默认取到Z列,即a-z列
    private int startRow = 1;//开始行 默认按headerNum
    private int endRow = -1;//结束行 默认取到最后一行

    public void configArea(String startColumn, String endColumn, int startRow, int endRow) {
        if (StringUtils.isNotBlank(startColumn)) {
            this.startColumn = startColumn;
        }
        if (StringUtils.isNotBlank(endColumn)) {
            this.endColumn = endColumn;
        }
        if (startRow > 0) {
            this.startRow = startRow;
        }
        if (endRow > -1) {
            this.endRow = endRow;
        }
    }

    /**
     * 用于收集导入解析失败的单元格数据
     */
    private List<ErrorMessage> errorMessageList = new ArrayList<>();
    /**
     * 字典翻译工具
     */
    private DictionaryTranslateHelper dictionaryTranslateHelper =DictionaryTranslateHelper.getInstance();
    /**
     * 主数据翻译工具
     */
    private EntityTranslateHelper entityTranslateHelper = EntityTranslateHelper.getInstance();
    /**
     * 构造函数
     *
     * @param file 导入文件对象，读取第一个工作表
     * @throws InvalidFormatException
     * @throws IOException
     */
    public ExcelImport(File file) throws InvalidFormatException, IOException {
        this(file, 0, 0);
    }

    /**
     * 构造函数
     *
     * @param file      导入文件对象，读取第一个工作表
     * @param headerNum 标题行数，数据行号=标题行数+1
     * @throws InvalidFormatException
     * @throws IOException
     */
    public ExcelImport(File file, int headerNum)
            throws InvalidFormatException, IOException {
        this(file, headerNum, 0);
    }

    /**
     * 构造函数
     *
     * @param file             导入文件对象
     * @param headerNum        标题行数，数据行号=标题行数+1
     * @param sheetIndexOrName 工作表编号或名称，从0开始
     * @throws InvalidFormatException
     * @throws IOException
     */
    public ExcelImport(File file, int headerNum, Object sheetIndexOrName)
            throws InvalidFormatException, IOException {
        this(file.getName(), new FileInputStream(file), headerNum, sheetIndexOrName);
    }

    /**
     * 构造函数
     *
     * @param multipartFile    导入文件对象
     * @param headerNum        标题行数，数据行号=标题行数+1
     * @param sheetIndexOrName 工作表编号或名称，从0开始
     * @throws InvalidFormatException
     * @throws IOException
     */
    public ExcelImport(MultipartFile multipartFile, int headerNum, Object sheetIndexOrName)
            throws InvalidFormatException, IOException {
        this(multipartFile.getOriginalFilename(), multipartFile.getInputStream(), headerNum, sheetIndexOrName);
    }

    /**
     * 构造函数
     *
     * @param fileName         导入文件对象
     * @param headerNum        标题行数，数据行号=标题行数+1
     * @param sheetIndexOrName 工作表编号或名称
     * @throws InvalidFormatException
     * @throws IOException
     */
    public ExcelImport(String fileName, InputStream is, int headerNum, Object sheetIndexOrName)
            throws InvalidFormatException, IOException {
        if (StringUtils.isBlank(fileName)) {
            throw new ExcelException("导入文档为空!");
        } else if (fileName.toLowerCase().endsWith("xls")) {
            this.wb = new HSSFWorkbook(is);
        } else if (fileName.toLowerCase().endsWith("xlsx")) {
            this.wb = new XSSFWorkbook(is);
        } else if (fileName.toLowerCase().endsWith("xlsm")) {
            this.wb = new XSSFWorkbook(is);//增加宏文件导入的支持
        }else {
            throw new ExcelException("文档格式不正确!");
        }
        this.setSheet(sheetIndexOrName, headerNum);
        log.debug("Initialize success.");
    }

    /**
     * 添加到 annotationList
     */
    private void addAnnotation(List<Object[]> annotationList, ExcelField ef, Object fOrM, Type type, String... groups) {
//		if (ef != null && (ef.type()==0 || ef.type()==type)){
        if (ef != null && (ef.type() == Type.ALL || ef.type() == type)) {
            if (groups != null && groups.length > 0) {
                boolean inGroup = false;
                for (String g : groups) {
                    if (inGroup) {
                        break;
                    }
                    for (String efg : ef.groups()) {
                        if (StringUtils.equals(g, efg)) {
                            inGroup = true;
                            annotationList.add(new Object[]{ef, fOrM});
                            break;
                        }
                    }
                }
            } else {
                annotationList.add(new Object[]{ef, fOrM});
            }
        }
    }

    /**
     * 获取当前工作薄
     *
     * @author zhilei.wang
     */
    public Workbook getWorkbook() {
        return wb;
    }

    /**
     * 设置当前工作表和标题行数
     *
     * @author zhilei.wang
     */
    public void setSheet(Object sheetIndexOrName, int headerNum) {
        if (sheetIndexOrName instanceof Integer || sheetIndexOrName instanceof Long) {
            this.sheet = this.wb.getSheetAt(Integer.parseInt(sheetIndexOrName + ""));
        } else {
            this.sheet = this.wb.getSheet(sheetIndexOrName.toString());
        }
        if (this.sheet == null) {
            throw new ExcelException("没有找到‘" + sheetIndexOrName + "’工作表!");
        }
        this.headerNum = headerNum;
    }

    /**
     * 获取行对象
     *
     * @param rownum
     * @return 返回Row对象，如果空行返回null
     */
    public Row getRow(int rownum) {
        Row row = this.sheet.getRow(rownum);
        if (row == null) {
            return null;
        }
        // 验证是否是空行，如果空行返回null
        short cellNum = 0;
        short emptyNum = 0;
        Iterator<Cell> it = row.cellIterator();
        while (it.hasNext()) {
            cellNum++;
            Cell cell = it.next();
            if (StringUtils.isBlank(cell.toString())) {
                emptyNum++;
            }
        }
        if (cellNum == emptyNum) {
            return null;
        }
        return row;
    }

    /**
     * 获取数据行号
     *
     * @return
     */
    public int getDataRowNum() {
        return headerNum;
    }

    /**
     * 获取最后一个数据行号
     *
     * @return
     */
    public int getLastDataRowNum() {
        //return this.sheet.getLastRowNum() + headerNum;
        return this.sheet.getLastRowNum() + 1;
    }

    /**
     * 获取最后一个列号
     *
     * @return
     */
    public int getLastCellNum() {
        Row row = this.getRow(headerNum);
        return row == null ? 0 : row.getLastCellNum();
    }

    /**
     * 获取单元格值
     *
     * @param row    获取的行
     * @param column 获取单元格列号
     * @return 单元格值
     */
    public Object getCellValue(Row row, int column) {
        if (row == null) {
            return row;
        }
        Object val = null;
        try {
            Cell cell = row.getCell(column);
            if (cell != null) {
                if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
                    val = cell.getNumericCellValue();
                    if (HSSFDateUtil.isCellDateFormatted(cell)) {
                        val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换
                    } else {
                        if ((Double) val % 1 != 0) {// 这里使用!=0,否则负数会出现问题
                            val = (Double) val;
                        } else {
                            val = new DecimalFormat("0").format(val);
                        }
                    }
                } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
                    val = cell.getStringCellValue();
                } else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
                    try {
                        val = cell.getStringCellValue();
                    } catch (Exception e) {
                        FormulaEvaluator evaluator = cell.getSheet().getWorkbook()
                                .getCreationHelper().createFormulaEvaluator();
                        evaluator.evaluateFormulaCell(cell);
                        CellValue cellValue = evaluator.evaluate(cell);
                        switch (cellValue.getCellType()) {
                            case Cell.CELL_TYPE_NUMERIC:
                                val = cellValue.getNumberValue();
                                break;
                            case Cell.CELL_TYPE_STRING:
                                val = cellValue.getStringValue();
                                break;
                            case Cell.CELL_TYPE_BOOLEAN:
                                val = cellValue.getBooleanValue();
                                break;
                            case Cell.CELL_TYPE_ERROR:
                                val = ErrorEval.getText(cellValue.getErrorValue());
                                break;
                            default:
                                val = cell.getCellFormula();
                        }
                    }
                } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
                    val = cell.getBooleanCellValue();
                } else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) {
                    val = cell.getErrorCellValue();
                }
            }
        } catch (Exception e) {
            log.error(e.getMessage());
        }
        return val;
    }

    /**
     * 获取导入数据列表
     *
     * @param cls    导入对象类型
     * @param groups 导入分组
     */
    public <E> List<E> getDataList(Class<E> cls, String... groups) throws InstantiationException, IllegalAccessException {
        return getDataList(cls, false, groups);
    }

    /**
     * 获取导入数据列表
     *
     * @param cls              导入对象类型
     * @param isThrowException 遇见错误是否抛出异常
     * @param groups           导入分组
     */
    public <E> List<E> getDataList(Class<E> cls, final boolean isThrowException, String... groups) throws InstantiationException, IllegalAccessException {
        return getDataList(cls, new MethodCall() {
            @Override
            public Object execute(Object... params) {
                if (isThrowException) {
                    Exception ex = (Exception) params[0];
                    int rowNum = (int) params[1];
                    int columnNum = (int) params[2];
                    throw new ExcelException("Get cell value [" + rowNum + "," + columnNum + "]", ex);
                }
                return null;
            }
        }, groups);
    }

    /**
     * 获取导入数据列表
     *
     * @param cls    导入对象类型
     * @param groups 导入分组
     */
    public <E> List<E> getDataList(Class<E> cls, MethodCall exceptionCallback, String... groups) throws InstantiationException, IllegalAccessException {
        errorMessageList.clear();
        if (cls.equals(Map.class)) {
            return getDataListAsMap(cls, exceptionCallback);
        }
        List<Object[]> annotationList = new ArrayList<>();
        // Get annotation field
        Field[] fs = cls.getDeclaredFields();
        for (Field f : fs) {
            ExcelField ef = f.getAnnotation(ExcelField.class);
            addAnnotation(annotationList, ef, f, Type.IMPORT, groups);
        }
        // Get annotation method
        Method[] ms = cls.getDeclaredMethods();
        for (Method m : ms) {
            ExcelField ef = m.getAnnotation(ExcelField.class);
            addAnnotation(annotationList, ef, m, Type.IMPORT, groups);
        }
        // Field sorting
        Collections.sort(annotationList, new Comparator<Object[]>() {
            @Override
            public int compare(Object[] o1, Object[] o2) {
                return new Integer(((ExcelField) o1[0]).sort()).compareTo(
                        new Integer(((ExcelField) o2[0]).sort()));
            }

        });
        //log.debug("Import column count:"+annotationList.size());
        // Get excel data
        List<E> dataList = new ArrayList<>();
        for (int i = this.getDataRowNum(); i < this.getLastDataRowNum(); i++) {
            E e = cls.newInstance();
            Row row = this.getRow(i);
            if (row == null) {
                continue;
            }
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < annotationList.size(); j++) {//Object[] os : annotationList){
                Object val = null;

                Object[] os = annotationList.get(j);
                ExcelField ef = (ExcelField) os[0];
                int column = (ef.column() != -1) ? ef.column() : j;
                try {
                    val = this.getCellValue(row, column);
                    if (val != null) {
                        // If is dict type, get dict value
                        if (StringUtils.isNotBlank(ef.dictType())) {
                            try {
                                String dataVal = dictionaryTranslateHelper.getDictValues(val.toString(), ef.dictType(), ef.dictField());
                                if (StringUtils.isBlank(dataVal)) {
                                    errorMessageList.add(new ErrorMessage(i + 1, column + 1, "字典[" + ef.dictType() + "]转义失败:" + val.toString(), ErrorMessage.ErrorType.DictException));
                                }
                                val = dataVal;
                            } catch (Exception ex) {
                                errorMessageList.add(new ErrorMessage(i + 1, column + 1, ex.getMessage(), ErrorMessage.ErrorType.Exception));
                                log.info("Get cell value [" + i + 1 + "," + column + 1 + "] error: " + ex.toString());
                                val = null;
                            }
                        }
                        // Get param type and type cast
                        Class<?> valType = Class.class;
                        if (os[1] instanceof Field) {
                            valType = ((Field) os[1]).getType();
                        } else if (os[1] instanceof Method) {
                            Method method = ((Method) os[1]);
                            if ("get".equals(method.getName().substring(0, 3))) {
                                valType = method.getReturnType();
                            } else if ("set".equals(method.getName().substring(0, 3))) {
                                valType = ((Method) os[1]).getParameterTypes()[0];
                            }
                        }

                        if (StringUtils.isNotBlank(ef.attrName())) {
                            val = entityTranslateHelper.getValue(valType, val.toString(), ef.attrName());
                        } else {
                            if (val != null) {
                                if (valType == String.class) {
                                    try {
                                        String s = String.valueOf(val.toString());
                                        if (StringUtils.endsWith(s, ".0")) {
                                            val = StringUtils.substringBefore(s, ".0");
                                        } else {
                                            val = String.valueOf(val.toString());
                                        }
                                        if (ef.length() != -1 && val.toString().length() > ef.length()) {
                                            errorMessageList.add(new ErrorMessage(i + 1, column + 1, "字符长度超长！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        }
                                    } catch (IllegalArgumentException ell) {
                                        errorMessageList.add(new ErrorMessage(i + 1, column + 1, "字符类型转换失败！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        log.info("Get cell value [" + i + 1 + "," + column + 1 + "] error: " + ell.toString());
                                        val = null;
                                        // 参数：Exception ex, int rowNum, int columnNum
                                        exceptionCallback.execute(ell, i, column);
                                    }
                                } else if (valType == Integer.class) {
                                    try {
                                        val = Double.valueOf(val.toString()).intValue();
                                        if (ef.length() != -1 && val.toString().length() > ef.length()) {
                                            errorMessageList.add(new ErrorMessage(i + 1, column + 1, "数值长度超长！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        }
                                    } catch (IllegalArgumentException ell) {
                                        errorMessageList.add(new ErrorMessage(i + 1, column + 1, "整型数字类型转换失败！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        log.info("Get cell value [" + i + 1 + "," + column + 1 + "] error: " + ell.toString());
                                        val = null;
                                        // 参数：Exception ex, int rowNum, int columnNum
                                        exceptionCallback.execute(ell, i, column);
                                    }

                                } else if (valType == Long.class) {
                                    try {
                                        val = Double.valueOf(val.toString()).longValue();
                                        if (ef.length() != -1 && val.toString().length() > ef.length()) {
                                            errorMessageList.add(new ErrorMessage(i + 1, column + 1, "数值长度超长！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        }
                                    } catch (IllegalArgumentException ell) {
                                        errorMessageList.add(new ErrorMessage(i + 1, column + 1, "长整型数字类型转换失败！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        log.info("Get cell value [" + i + 1 + "," + column + 1 + "] error: " + ell.toString());
                                        val = null;
                                        // 参数：Exception ex, int rowNum, int columnNum
                                        exceptionCallback.execute(ell, i, column);
                                    }
                                } else if (valType == BigDecimal.class) {
                                    try {
                                        val = new BigDecimal(val.toString());
                                        if (ef.length() != -1 && val.toString().length() > ef.length()) {
                                            errorMessageList.add(new ErrorMessage(i + 1, column + 1, "数值长度超长！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        }
                                    } catch (IllegalArgumentException ell) {
                                        errorMessageList.add(new ErrorMessage(i + 1, column + 1, "数字类型转换失败！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        log.info("Get cell value [" + i + 1 + "," + column + 1 + "] error: " + ell.toString());
                                        val = null;
                                        // 参数：Exception ex, int rowNum, int columnNum
                                        exceptionCallback.execute(ell, i, column);
                                    }
                                } else if (valType == Double.class) {
                                    try {
                                        val = Double.valueOf(val.toString());
                                        if (ef.length() != -1 && val.toString().length() > ef.length()) {
                                            errorMessageList.add(new ErrorMessage(i + 1, column + 1, "数值长度超长！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        }
                                    } catch (IllegalArgumentException ell) {
                                        errorMessageList.add(new ErrorMessage(i + 1, column + 1, "数字类型转换失败！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        log.info("Get cell value [" + i + 1 + "," + column + 1 + "] error: " + ell.toString());
                                        val = null;
                                        // 参数：Exception ex, int rowNum, int columnNum
                                        exceptionCallback.execute(ell, i, column);
                                    }
                                } else if (valType == Float.class) {
                                    try {
                                        val = Float.valueOf(val.toString());
                                        if (ef.length() != -1 && val.toString().length() > ef.length()) {
                                            errorMessageList.add(new ErrorMessage(i + 1, column + 1, "数值长度超长！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        }
                                    } catch (IllegalArgumentException ell) {
                                        errorMessageList.add(new ErrorMessage(i + 1, column + 1, "浮点数字类型转换失败！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        log.info("Get cell value [" + i + 1 + "," + column + 1 + "] error: " + ell.toString());
                                        val = null;
                                        // 参数：Exception ex, int rowNum, int columnNum
                                        exceptionCallback.execute(ell, i, column);
                                    }
                                } else if (valType == Date.class) {
                                    try {
                                        if (val instanceof String) {
                                            val = DateUtils.parseDate(val);
                                        } else if (val instanceof Double) {
                                            val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换
                                        }
                                    } catch (IllegalArgumentException ell) {
                                        errorMessageList.add(new ErrorMessage(i + 1, column + 1, "日期类型转换失败！", ErrorMessage.ErrorType.IllegalArgumentException));
                                        log.info("Get cell value [" + i + 1 + "," + column + 1 + "] error: " + ell.toString());
                                        val = null;
                                        // 参数：Exception ex, int rowNum, int columnNum
                                        exceptionCallback.execute(ell, i, column);
                                    }
                                }
                            }
                        }
                        // set entity value
                        if (StringUtils.isNotBlank(ef.attrName())) {
                            PropertyUtils.setProperty(e, StringUtils.substringBefore(ef.attrName(), "."), val);
                        } else {
                            if (os[1] instanceof Field) {
                                PropertyUtils.setProperty(e, ((Field) os[1]).getName(), val);
                            } else if (os[1] instanceof Method) {
                                String mthodName = ((Method) os[1]).getName();
                                if ("get".equals(mthodName.substring(0, 3))) {
                                    mthodName = "set" + StringUtils.substringAfter(mthodName, "get");
                                }
                                Reflections.invokeMethod(e, mthodName, new Class[]{valType}, new Object[]{val});
                            }
                        }
                    }
                    sb.append(val + ", ");
                } catch (IllegalArgumentException ell) {
                    errorMessageList.add(new ErrorMessage(i + 1, column + 1, ell.getMessage(), ErrorMessage.ErrorType.IllegalArgumentException));
                    log.info("Get cell value [" + i + 1 + "," + column + 1 + "] error: " + ell.toString());
                    val = null;
                    // 参数：Exception ex, int rowNum, int columnNum
                    exceptionCallback.execute(ell, i, column);
                } catch (Exception ex) {
                    errorMessageList.add(new ErrorMessage(i + 1, column + 1, ex.getMessage(), ErrorMessage.ErrorType.Exception));
                    log.info("Get cell value [" + i + 1 + "," + column + 1 + "] error: " + ex.toString());
                    val = null;
                    // 参数：Exception ex, int rowNum, int columnNum
                    exceptionCallback.execute(ex, i, column);
                }
            }
            dataList.add(e);
            log.debug("Read success: [" + i + "] " + sb.toString());
        }

        return dataList;
    }

    /**
     * 使用Map接excel中的数据
     *
     * @param cls
     * @param exceptionCallback
     * @param <E>
     * @return
     */
    private <E> List<E> getDataListAsMap(Class<E> cls, MethodCall exceptionCallback) {
        List<E> list = new ArrayList<>();
        if (endRow == -1) {
            endRow = getLastDataRowNum();
        }
        //将行号转换成下标
        int startColumnIndex = ExcelUtils.toExcelIndex(startColumn);
        int endColumnIndex = ExcelUtils.toExcelIndex(endColumn);
        int startRowIndex = startRow - 1;
        int endRowIndex = endRow - 1;
        for (int i = startRowIndex; i <= endRowIndex; i++) {
            Row row = this.getRow(i);
            if (row == null) {
                continue;
            }
            StringBuilder sb = new StringBuilder();
            Map<String, Object> map = new HashMap<>();
            for (int j = startColumnIndex; j <= endColumnIndex; j++) {
                Object val = this.getCellValue(row, j);
                map.put(ExcelUtils.toExcelName(j) + "_" + (i + 1), val);
            }
            list.add((E) map);
        }
        return list;
    }

    public List<ErrorMessage> getErrorMessageList() {
        return errorMessageList;
    }

    /**
     * 清理临时文件
     *
     * @deprecated see close()
     */
    public ExcelImport dispose() {
        try {
            this.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return this;
    }

    @Override
    public void close() {
        dictionaryTranslateHelper.clear();// 清理掉本次的字典缓存
        entityTranslateHelper.clear();//清理主数据缓存
    }

    //	/**
//	 * 导入测试
//	 */
//	public static void main(String[] args) throws Throwable {
//		
//		ImportExcel ei = new ImportExcel("target/export.xlsx", 1);
//		
//		for (int i = ei.getDataRowNum(); i < ei.getLastDataRowNum(); i++) {
//			Row row = ei.getRow(i);
//			if (row == null){
//				continue;
//			}
//			for (int j = 0; j < ei.getLastCellNum(); j++) {
//				Object val = ei.getCellValue(row, j);
//				System.out.print(val+", ");
//			}
//			System.out.println();
//		}
//		
//	}
    public static void main(String[] args) {
        Class b = ExcelImport.class;
        Class c = int.class;
        System.out.println(b == Class.class);//
        System.out.println(c == Class.class);//false
    }

}
